package org.realogic.cfm.common.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class EntityDatas<T> implements Serializable {

	private static final long serialVersionUID = -1621538657674815409L;

	private int size;
	private List<T> newList;
	private List<T> modifiedList;
	private List<T> deletedList;
	
	public EntityDatas() {
		this(10);
	}

	public EntityDatas(int size) {
		this.size = size;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public List<T> getNewList() {
		return newList;
	}

	public List<T> getModifiedList() {
		return modifiedList;
	}

	public List<T> getDeletedList() {
		return deletedList;
	}

	public void addNeedNew(T entity) {
		if (newList == null) {
			newList = new ArrayList<T>(size);
		}
		newList.add(entity);
	}

	public void addNeedModified(T entity) {
		if (modifiedList == null) {
			modifiedList = new ArrayList<T>(size);
		}
		modifiedList.add(entity);
	}

	public void addNeedDeleted(T entity) {
		if (deletedList == null) {
			deletedList = new ArrayList<T>(size);
		}
		deletedList.add(entity);
	}
}
